﻿package mortal.game.scene3D.ai.ais
{
    import Message.Public.*;
    import flash.geom.*;
    import flash.utils.*;
    import frEngine.event.*;
    import mortal.game.*;
    import mortal.game.mvc.*;
    import mortal.game.scene3D.ai.base.*;
    import mortal.game.scene3D.events.*;

    public class JumpAI extends AICommand
    {
        private var _lastJumpTimer:int = -1;

        public function JumpAI()
        {
            return;
        }// end function

        override public function start(param1:Function = null) : void
        {
            super.start(param1);
            var _loc_2:* = new SPoint();
            _loc_2.x = Point(data.target).x * Game.mapInfo.pieceWidth;
            _loc_2.y = Point(data.target).y * Game.mapInfo.pieceHeight;
            this._lastJumpTimer = getTimer();
            FrEventDispatcher.instance.proxyAddEventListener(data.meRole, PlayerEvent.JumpPointEnd, this.jumpEndHandler);
            GameProxy.sceneProxy.jumpPoint(_loc_2);
            return;
        }// end function

        private function jumpEndHandler(event:ParamsEvent) : void
        {
            FrEventDispatcher.instance.proxyRemoveEventListener(data.meRole, PlayerEvent.JumpPointEnd, this.jumpEndHandler);
            endAI();
            return;
        }// end function

        override public function get stopable() : Boolean
        {
            if (getTimer() - this._lastJumpTimer >= 1000)
            {
                return true;
            }
            return false;
        }// end function

    }
}
